<template>
	<view>
		<page-head :title="`审批`" :headtype="2"></page-head>
		<block v-if="assessusermsg.type == 2">
			<!-- 审核员1 -->
			<view class="submittime marginAuto" v-if="addmyinvoice.audit1_status == 0">提交时间：{{ addmyinvoice.create_time }}</view>
			<view class="sanctionend marginAuto" v-if="addmyinvoice.audit1_status != 0">
				<view class="sanctionendstatus" style="color:#40C40C;" v-if="addmyinvoice.audit1_status == 1">已通过</view>
				<view class="sanctionendstatus" style="color:#E51818;" v-if="addmyinvoice.audit1_status == 2">已拒绝</view>
				<view class="sanctionendtime">
					<text style="color:#666666;">审批时间:</text>
					<text style="color:#333333;font-weight:600;">{{ timegs(addmyinvoice.audit1_time) }}</text>
				</view>
			</view>
		</block>
		<block v-if="assessusermsg.type == 3">
			<!-- 审核员2 -->
			<view class="submittime marginAuto" v-if="addmyinvoice.audit2_status == 0">提交时间：{{ addmyinvoice.create_time }}</view>
			<view class="sanctionend marginAuto" v-if="addmyinvoice.audit2_status != 0">
				<view class="sanctionendstatus" style="color:#40C40C;" v-if="addmyinvoice.audit2_status == 1">已通过</view>
				<view class="sanctionendstatus" style="color:#E51818;" v-if="addmyinvoice.audit2_status == 2">已拒绝</view>
				<view class="sanctionendtime">
					<text style="color:#666666;">审批时间:</text>
					<text style="color:#333333;font-weight:600;">{{ timegs(addmyinvoice.audit2_time) }}</text>
				</view>
			</view>
		</block>
		<view class="xqblock marginAuto">
			<view class="item flex">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">企业名称：</view>
					<view class="itemmsgmsg">{{ addmyinvoice.company_name }}</view>
				</view>
			</view>
			<view class="item flex">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">企业类型：</view>
					<view class="itemmsgmsg" v-if="companytypeg">工业</view>
					<view class="itemmsgmsg" v-if="companytypen">农业</view>
				</view>
			</view>
			<view class="item">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">营业执照：</view>
				</view>
				<view class="itemphoto">
					<image :src="apifun.URLimg + addmyinvoice.business_img" mode="heightFix"></image>
				</view>
			</view>
			<view class="item">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">授权书：</view>
				</view>
				<view class="itemphoto">
					<image :src="apifun.URLimg + addmyinvoice.authorization" mode="heightFix"></image>
				</view>
			</view>
			<view class="item flex" @click="apifun.navigate('/pages/usermy/invoice','noedit=2')">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">开票信息：</view>
				</view>
				<view class="itemicon">
					<uv-icon name="arrow-right" color="#999999" size="20"></uv-icon>
				</view>
			</view>
		</view>
		<view class="sanctionr" v-if="addmyinvoice.audit1_status > 0 || addmyinvoice.audit2_status > 0">
			<view class="sanctionrtitle marginAuto">审批员</view>
			<view class="sanctionreach flex marginAuto" v-if="addmyinvoice.audit1_status > 0">
				<view class="sqiteml">
					<image v-if="addmyinvoice.auditor1_avatar" :src="apifun.URLimg + addmyinvoice.auditor1_avatar" mode=""></image>
					<image v-if="!addmyinvoice.auditor1_avatar" src="../../static/logo.png" mode=""></image>
				</view>
				<view class="sqitemc">
					<view class="sqitemctitle ellipsis01">{{ addmyinvoice.auditor1_name }}</view>
					<view class="sqitemctime">审批时间：{{ timegs(addmyinvoice.audit1_time) }}</view>
				</view>
				<view class="sqitemr">
					<view class="sqitemrstatus">
						<view class="sqiteml marginAuto" style="width:60rpx;height:50rpx;" v-if="addmyinvoice.audit1_status == 1">
							<uv-icon name="checkmark-circle-fill" :color="'#2340FF'" size="20"></uv-icon>
						</view>
						<view class="sqiteml marginAuto" style="width:60rpx;height:50rpx;" v-if="addmyinvoice.audit1_status == 2">
							<uv-icon name="close-circle-fill" :color="'#E51818'" size="20"></uv-icon>
						</view>
					</view>
					<view class="sqitemrbtn">
						<!-- <text style="color:#E51818;margin-top:20rpx;" v-if="addmyinvoice.audit1_status == 0">待审批</text> -->
						<text style="color:#2340FF" v-if="addmyinvoice.audit1_status == 1">通过</text>
						<text style="color:#E51818;" v-if="addmyinvoice.audit1_status == 2">拒绝</text>
					</view>
				</view>
			</view>
			<view class="sanctionreach flex marginAuto" v-if="addmyinvoice.audit2_status > 0">
				<view class="sqiteml">
					<image v-if="addmyinvoice.auditor2_avatar" :src="apifun.URLimg + addmyinvoice.auditor2_avatar" mode=""></image>
					<image v-if="!addmyinvoice.auditor2_avatar" src="../../static/logo.png" mode=""></image>
				</view>
				<view class="sqitemc">
					<view class="sqitemctitle ellipsis01">{{ addmyinvoice.auditor2_name }}</view>
					<view class="sqitemctime">审批时间：{{ timegs(addmyinvoice.audit2_time) }}</view>
				</view>
				<view class="sqitemr">
					<view class="sqitemrstatus">
						<view class="sqiteml marginAuto" style="width:60rpx;height:50rpx;" v-if="addmyinvoice.audit2_status == 1">
							<uv-icon name="checkmark-circle-fill" :color="'#2340FF'" size="20"></uv-icon>
						</view>
						<view class="sqiteml marginAuto" style="width:60rpx;height:50rpx;" v-if="addmyinvoice.audit2_status == 2">
							<uv-icon name="close-circle-fill" :color="'#E51818'" size="20"></uv-icon>
						</view>
					</view>
					<view class="sqitemrbtn">
						<!-- <text style="color:#E51818;margin-top:20rpx;" v-if="addmyinvoice.audit2_status == 0">待审批</text> -->
						<text style="color:#2340FF" v-if="addmyinvoice.audit2_status == 1">通过</text>
						<text style="color:#E51818;" v-if="addmyinvoice.audit2_status == 2">拒绝</text>
					</view>
				</view>
			</view>
		</view>
		<view class="funbtn marginAuto flex" v-if="assessusermsg.type == 2 && addmyinvoice.audit1_status == 0">
			<view class="funbtneach" style="background:#FFD6D6;color:#E51818;" @click="$refs.jjpopup.open()">拒绝</view>
			<view class="funbtneach mainBg baiColor" @click="$refs.typopup.open()">同意</view>
		</view>
		<view class="funbtn marginAuto flex" v-if="assessusermsg.type == 3 && addmyinvoice.audit2_status == 0">
			<view class="funbtneach" style="background:#FFD6D6;color:#E51818;" @click="$refs.jjpopup.open()">拒绝</view>
			<view class="funbtneach mainBg baiColor" @click="$refs.typopup.open()">同意</view>
		</view>
		<uv-popup ref="typopup" mode="center" round="20">
			<view class="noticepup">
				<view class="noticepuptitle"><text class="noticepuptitlemsg">确定同意审批信息吗？</text></view>
				<view class="boticebtn flex">
					<view class="boticebtneach closebtn" @click="$refs.typopup.close()">取消</view>
					<view class="boticebtneach mainBg baiColor" @click="checkfun(1)">确定</view>
				</view>
			</view>
		</uv-popup>
		<uv-popup ref="jjpopup" mode="center" round="20">
			<view class="noticepup">
				<view class="noticepuptitle"><text class="noticepuptitlemsg">确定拒绝审批信息吗？</text></view>
				<view class="boticebtn flex">
					<view class="boticebtneach closebtn" @click="$refs.jjpopup.close()">取消</view>
					<view class="boticebtneach mainBg baiColor" @click="checkfun(2)">确定</view>
				</view>
			</view>
		</uv-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apifun:this.apifun,
				id:'',
				addmyinvoice:{},
				companytypeg:false,
				companytypen:false,
				assessusermsg:{}
			};
		},
		onLoad(option) {
			this.id = option.id;
			this.assessusermsg = uni.getStorageSync('assessusermsg');
			// console.log(this.assessusermsg)
			this.getbusinmsgfun()
		},
		methods: {
			checkfun(type){
				let sendData= {
					ids:this.id,
					status:type
				}
				this.apifun.unirequest('/auditor/index/accountAudit','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.apifun.toast('操作成功');
						setTimeout(()=>{
							this.$refs.typopup.close();
							this.$refs.jjpopup.close();
							this.apifun.goback();
						},1500)
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			getbusinmsgfun(){
				this.apifun.unirequest('/auditor/index/getAccountAuditDetail','post',{
					id:this.id
				},(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.addmyinvoice = datas;
						this.companytypeg = datas.company_type.includes('1');
						this.companytypen = datas.company_type.includes('2');
						this.business = datas.business_img;
						this.sqs = datas.authorization;
						let sendData = {
							invoice_type:datas.invoice_type,
							invoice_title:datas.invoice_title,
							invoice_tax:datas.invoice_tax,
							reg_address:datas.reg_address,
							reg_tel:datas.reg_tel,
							bank_name:datas.bank_name,
							bank_account:datas.bank_account
						}
						uni.setStorageSync('addmyinvoice', sendData);
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			timegs(time){
				return uni.$uv.timeFormat(time,'yyyy年mm月dd日 hh:MM:ss')
			}
		}
	};
</script>

<style scoped lang="scss">
page{
	background: #FBFBFB;
	padding-bottom: 100rpx;
}
.submittime{
	width: 690rpx;
	font-size: 32rpx;
	color: #333333;
	line-height: 60rpx;
	padding: 10rpx 0;
	font-weight: 600;
}
.sanctionend{
	width: 690rpx;
	padding: 20rpx 0;
	.sanctionendstatus{
		font-size: 34rpx;
		margin-bottom: 20rpx;
	}
	.sanctionendtime{
		font-size:28rpx;
	}
}
.xqblock{
	position: relative;
	width: 630rpx;
	padding: 20rpx 30rpx;
	// background:linear-gradient(to bottom, #F4FAFF,#ffffff);
	background: #fff;
	border-radius: 10rpx;
	margin-top: 20rpx;
	border:1px solid #EFF1F6;
	margin-top:20rpx;
	justify-content: space-between;
	.item{
		padding: 20rpx 0;
		justify-content: space-between;
		.itemphoto{
			margin-top: 20rpx;
			image{
				height: 220rpx;
			}
		}
		.itemmsg{
			.itemmsgimg{
				width: 40rpx;
				height: 40rpx;
				image{
					width: 40rpx;
					height: 40rpx;
				}
			}
			.itemmsgtitle{
				line-height: 40rpx;
				font-size: 30rpx;
				color:#666666;
			}
			.itemmsgmsg{
				line-height: 40rpx;
				font-size: 30rpx;
				color:#333;
				margin-left: 10rpx;
				font-weight: 600;
			}
		}
	}
}
.funbtn{
	width: 80%;
	margin-top:100rpx;
	justify-content: space-between;
	.funbtneach{
		width: 240rpx;
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		border-radius: 10rpx;
		font-size:30rpx;
	}
}
// popup
.noticepup{
	position: relative;
	width: 600rpx;
	border-radius:30rpx;
	.noticepuptitle{
		position: relative;
		width: 600rpx;
		height: 240rpx;
		font-weight: 600;
		background:linear-gradient(to bottom, #B0D9FF,#ffffff);
		.noticepuptitlemsg{
			position: absolute;
			top:120rpx;
			width: 600rpx;
			height: 70rpx;
			color:#333333;
			font-size: 34rpx;
			text-align: center;
		}
	}
	.boticebtn{
		margin-top:30rpx;
		color: #fff;
		font-size:30rpx;
		width: 600rpx;
		height:100rpx;
		line-height: 100rpx;
		text-align: center;
		.closebtn{
			color:#2340FF;
			background-color: #DBEEFF;
		}
		.boticebtneach{
			width: 50%;
		}
	}
}
// 审批员

.sanctionr{
	.sanctionrtitle{
		width: 690rpx;
		line-height: 50rpx;
		font-size: 32rpx;
		color: #333333;
		padding: 10rpx 0;
	}
	.sanctionreach{
		margin-top:20rpx;
		background:#fff;
		width: 630rpx;
		padding:20rpx 30rpx;
		border-radius: 20rpx;
		justify-content: space-between;
		.sqiteml{
			width: 80rpx;
			height: 80rpx;
			margin-right: 10rpx;
			image{
				width: 80rpx;
				height: 80rpx;
				border-radius: 100rpx;
			}
		}
		.sqitemc{
			width:65%;
			.sqitemctitle{
				font-size: 30rpx;
				color: #333333;
				font-weight: 600;
				line-height: 50rpx;
			}
			.sqitemctime{
				font-size:24rpx;
				color:#666666;
				line-height: 50rpx;
			}
		}
		.sqitemr{
			.sqitemrstatus{
				font-size: 24rpx;
				line-height: 60rpx;
				text-align: center;
			}
			.sqitemrbtn{
				width: 100rpx;
				line-height:60rpx;
				border-radius:10rpx;
				font-size: 30rpx;
				color: #fff;
				text-align: center;
			}
			
		}
	}
}
</style>